package stream;

import java.util.Arrays;
import java.util.List;

public class InStream {
    public static void main(String[] args) {

        List<Goods> goods= Arrays.asList(
                new Goods("Apple", 10),
                new Goods("Banana", 5),
                new Goods("Bread", 3),
                new Goods("Milk", 15),
                new Goods("Wine", 20));
        //将Good对象流映射到价格流（整数流） 并求出价格总和
        int priceSum=goods.stream().mapToInt(g->g.getPrice()).sum();
        System.out.println(priceSum);//53

//
//        List<Goods> goods=Arrays.asList(
//                new Goods("Apple", 10),
//                new Goods("Banana", 5),
//                new Goods("Bread", 3),
//                new Goods("Milk", 15),
//                new Goods("Wine", 20));
//        IntStream intStream=goods.stream().mapToInt(g->g.getPrice());
//        Stream<Integer> stream=intStream.boxed();


    }

}
